﻿@using System.Runtime.Remoting.Messaging
@model ViewModels.BoardVM.BoardDetailVM

@{
    ViewBag.Title = "Hinoky.com - " + Html.DisplayFor(model => model.BoardData.Title);
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section metatags {
    <meta name="keywords" content="@Model.BoardData.SearchTag" />
}

<style type="text/css">
    .alert {
        padding: 5px 10px 5px 10px;
    }
</style>

<script src="~/Scripts/customJS/guestbookLib.js"></script>

<script type="text/javascript">
    $(document).ready(function() {
        $("#btnList").on("click", function() {
            location.href = "/board/list?" + '@ViewBag.Pamameters';
        });

        $("#btnModify").on("click", function() {
            location.href = "/Board/Edit/" + $("#hidIdx").val();
        });
        
        $("#btnRemove").on("click", function () {
            bootbox.confirm("삭제하시겠습니까?", function (result) { if (result) deleteContent(); });
        });

        //$("#divFaceBookShare").attr("data-href", location.origin);

        var deleteContent = function() {
            $.ajax({
                type: "POST",
                async: true,
                url: "/Board/Delete",
                data: { id: $("#hidIdx").val() },
                success: function (data) {
                    if (data.Success == true) {
                        bootbox.alert("삭제되었습니다.", function () { location.href = "/board/List"; });
                    }
                    else {
                        bootbox.alert("삭제에 실패하였습니다.", null);
                    }
                },
                error: function (xhr, status, error) {
                    alert(error);
                }
            });
        }
    });

    guestbookLib({ locationCode: 'ARTICLE', subKey: '@Model.BoardData.Idx', addButtonName: 'btnGuestbookAdd', isAjaxCall : true, isUseSecret: false });

    function goList(category) {
        location.href = "/board/list?category=" + escape(category);
    }
</script>

@{
    bool isAdmin = WebLib.AuthorizeService.MemberInfo.Instance.IsSignIn && WebLib.AuthorizeService.MemberInfo.Instance.UserRole.Contains("ADMIN");
}

<div class="bs-callout bs-callout-article">
    <h3>Article</h3>
    <p>주절 주절 게시판 입니다.</p>
</div>

<form id="form1">
    <div>
    
        <div class="featurebox_center" style="margin-top:20px" >
            <input type="hidden" id="hidIdx" name="hidIdx" value="@Model.BoardData.Idx" />
            <table style="width:100%; height:40px; " >
                <tr>
                    <td style="vertical-align:top" >
                        <h4 class="text-danger" >@Html.DisplayFor(model => model.BoardData.Title)</h4>
                        @Html.Raw("- Writen by " + Model.BoardData.WriteUserName + "(" + Model.BoardData.WriteUserId + ")")
                        
                        @if (!Model.BoardData.IsDisplay && isAdmin)
                        {
                            <label style="color:red">비공개중입니다.</label>   
                        }
                    </td>
                    <td style="text-align:right">
                        <h5 style="font-weight:normal" >@Html.DisplayFor(model => model.BoardData.WriteDate)</h5>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" style="text-align:right" >
                        <div id="divFaceBookShare" class="fb-share-button" data-href="/board/details/@Model.BoardData.Idx" data-width="100px" data-type="button_count" />
                    </td>
                </tr>
            </table>
            <p />
            <div class="" >
                @Html.Raw(Model.BoardData.Body)
            </div>
            <br/>
            <table style="width:100%; font-family: verdana, arial, sans-serif; font-size: 12px;" >
                <tr>
                    <td>
                        <b>관련 카테고리</b> :
                        @for (var i = 0; i < Model.BoardData.Categories.Length; i++)
                        {
                            <a href="#" onclick="goList('@Model.BoardData.Categories[i]');return false;" class="btn btn-xs btn-info" >@Model.BoardData.Categories[i]</a>
                        }
                    </td>
                    <td>
                    </td>
                </tr>
            </table>
            <div class="row button_area" >
                <div class="col-md-6" >
                    
                </div>
                <div class="col-md-6 text-right" >
                    <input type="button" id="btnList" value="List" class="btn btn-default" />
                    @if (isAdmin)
                    {
                        <input type="button" id="btnModify" value="Modify" class="btn btn-default" /> 
                        <input type="button" id="btnRemove" value="Delete" class="btn btn-danger" />
                    }
                </div>
            </div>
        </div>
        
        <!-- (s) 댓글리스트 영역 (s) -->
        <br />
        <div class="well">+ 
            <div class="row">
                <div class="col-md-6">
                    <span class="glyphicon glyphicon-pencil" style="font-weight:bold; font-size:15px " >&nbsp;Comments</span>
                </div>
                <div class="col-md-6 text-right">
                    <a id="btnGuestbookAdd" class="btn btn-info">글 남기기</a>
                </div>
            </div>
            
            <hr />
            <div id="divGuestBookList">
                <input type="hidden" id="hidLastGuestBookIdx" name="hidLastGuestBookIdx" value="" />
            </div>
            <!-- (e) 댓글리스트 영역 (e) -->
        </div>
    </div>
</form>